new Vue({
    el: "#container",
    data() {
        return {
            tableSearch: {
                pageIndex: 0,
                limit: 50,
                total: 0,
                dateFormat: "yyyy-MM-dd HH:mm",
                operateType: null,
                startTime: null,
                endTime: null,
                searchVal: "",
            },
            typeList: null,
            //  表数据
            tableDatas: [],
            tableLoading: false,
            detailDialog: {
                show: false,
                invoiceId: false,
            },
        }
    },
    // 在模板渲染成html前调用
    created() {
        var that = this;
        that.typeList = typeList;
        that.loadTableDatas();
    },
    // 在模板渲染成html后调用，通常是初始化页面完成后，再对html的dom节点进行一些需要的操作
    mounted() {
        var that = this;
    },
    methods: {
        searchDatas() {
            let that = this;
            that.tableSearch.pageIndex = 0;
            that.tableSearch.limit = 50;
            that.loadTableDatas();
        },
        // 加载数据
        loadTableDatas: function () {
            let that = this;
            that.tableLoading = true;
            $.ajax({
                type: "POST",
                url: "/pro/invoice/handle/page",
                async: true,
                dataType: 'json',
                data: that.tableSearch,
                success: function (res) {
                    if (res.code == 0) {
                        let page = res.data;
                        that.tableDatas = page.records;
                        that.tableSearch.total = page.total;
                    } else {
                        that.$message({
                            showClose: true,
                            message: '查询发货单失败：' + res.msg,
                            type: 'error'
                        });
                    }
                },
                error: function (res) {
                    that.$message({
                        showClose: true,
                        message: '请求失败，请联系管理员',
                        type: 'error'
                    });
                    return;
                },
                complete: function (XMLHttpRequest, status) {
                    that.tableLoading = false;
                }
            })
        },
        /**
         * 显示发货单详情
         * @param invoiceId
         */
        showInvDetail(invoiceId) {
            let that = this;
            that.detailDialog.show = true;
            that.detailDialog.invoiceId = invoiceId;
        },
        // 修改每页数据
        handleSizeChange(val) {
            var that = this;
            that.tableSearch.limit = val;
            // 查询数据
            that.loadTableDatas();
        },
        handleCurrentChange(val) {
            // 设置页数
            var that = this;
            that.tableSearch.pageIndex = val;
            that.loadTableDatas();
        },
    }
})
